<template>
	<view>
		<table>
			<tr>
				<td>头像:</td>
				<td>
					<image class="avatar-img" :src="userInfo.avatar?userInfo.avatar:'/static/images/empty-avatar.png'"
						mode="widthFix">
					</image>
				</td>
			</tr>
			<tr>
				<td>名称:</td>
				<td v-if="!userInfo.nickname">去取个好听的昵称吧</td>
				<td v-else >{{userInfo.nickname}}</td>
			</tr>
			<tr>
				<td>手机号:</td>
				<td>{{userInfo.mobile}}</td>
			</tr>
			<tr>
				<td><button  @click.stop="toPage('pages/user/updateuser')">修改信息</button></td>
			</tr>
		</table>
	</view>
</template>

<script>
	import {getUserInfo} from '@/utils/api/user_info.js';
	export default {
		data() {
			return {
				userInfo: {}
			}
		},
		methods: {
			GetUserInfo() {
				getUserInfo({from: "userinfo"}).then(res => {
						if (res.data.code != 0) {
							return
						}
						this.userInfo =  res.data.data
					});
				
			},
			async toPage(url) {
				this.$tools.toPage(url)
			},
		},
		mounted() {
			this.GetUserInfo()
		}
	}
</script>

<style>
	.avatar-img {
		width: 120rpx;
		border-radius: 10%;
		background: #eee;
	}
</style>